<template>
  <div>
    <van-swipe :autoplay="3000">
      <van-swipe-item v-for="item in list" :key="item.id">
        <img v-lazy="`http://124.223.73.204:8080${item.imgSrc}`" />
      </van-swipe-item>
    </van-swipe>
    <div class="swipe_hd">
      <div class="search">
        <div class="location">
          <span class="city">上海</span>
          <van-icon name="arrow-down" />
        </div>
        <div class="formInp">
          <van-icon name="search" />
          <span class="text">请输入小区或地址</span>
        </div>
      </div>
      <div id="icoMap">
        <van-icon name="aim" />
      </div>
    </div>
    <van-grid :border="false" :column-num="4">
      <van-grid-item>
        <div id="circular">
          <van-icon name="wap-home-o" />
        </div>
        <div class="rentText">整租</div>
      </van-grid-item>

      <van-grid-item>
        <div id="circular">
          <van-icon name="friends-o" />
        </div>
        <div class="rentText">合租</div>
      </van-grid-item>

      <van-grid-item>
        <div id="circular">
          <van-icon name="location-o" />
        </div>
        <div class="rentText">地图找房</div>
      </van-grid-item>

      <van-grid-item>
        <div id="circular">
          <van-icon name="wap-home-o" />
        </div>
        <div class="rentText">去出租</div>
      </van-grid-item>
    </van-grid>

    <!-- 租房小组 -->
    <div class="rent_group">
      <div class="rent_group_hd">
        <em>租房小组</em>
        <i>更多</i>
      </div>
      <div class="rent_group_bd">
        <!-- 四宫格 -->
        <!-- <van-grid direction="horizontal" :column-num="2">
          <van-grid-item icon="photo-o" text="文字" />
          <van-grid-item icon="photo-o" text="文字" />
          <van-grid-item icon="photo-o" text="文字" />
          <van-grid-item icon="photo-o" text="文字" />
        </van-grid> -->
        <ul>
          <li v-for="item in rentlist" :key="item.id">
            <div class="li_l">
              <p>{{ item.title }}</p>
              <span>{{ item.desc }}</span>
            </div>
            <div class="li_r">
              <img :src="`http://124.223.73.204:8080${item.imgSrc}`" alt="" />
            </div>
          </li>
        </ul>
      </div>
    </div>
    <!-- 最新资讯 -->
    <div class="newmessage">
      <p>最新资讯</p>
      <!-- 房屋信息 -->
      <div class="houseinfo" v-for="item in newsList" :key="item.id">
        <div class="info_l">
          <img :src="`http://124.223.73.204:8080${item.imgSrc}`" alt="" />
        </div>
        <div class="info_r">
          <h5>{{ item.title }}</h5>
          <span>{{ item.from }}</span>
          <i>{{ item.date }}</i>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { swipe, rentgroup, homenews } from '@/api/home'

export default {
  data () {
    return {
      list: [],
      rentlist: [],
      newsList: []
    }
  },
  methods: {
    async getswipe () {
      const res = await swipe()
      // console.log(res.body)
      this.list = res.body
    },
    async rentgroup () {
      const res = await rentgroup()
      // console.log(res.body)
      this.rentlist = res.body
      // console.log(this.rentlist)
    },
    async homenews () {
      const res = await homenews()
      console.log(res.body)
      this.newsList = res.body
    }
  },
  created () {
    this.getswipe()
    this.rentgroup()
    this.homenews()
  }
}
</script>

<style scoped lang='less'>
* {
  box-sizing: border-box;
  padding: 0;
  margin: 0;
}
em,
i {
  font-style: normal;
}
ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}
li {
  display: flex;
  font-size: 14px;
  width: 170px;
  height: 120px;
  background-color: #fff;
  list-style: none;
  margin-bottom: 10px;
  padding-left: 20px;
  p {
    margin-top: 30px;
  }
  span {
    color: #9ca0a2;
  }
  img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-top: 35px;
    margin-left: 20px;
  }
}
.van-swipe {
  position: relative;
  width: 375px;
  height: 210px;
  img {
    width: 375px;
  }
}
.swipe_hd {
  position: absolute;
  display: flex;
  justify-content: space-between;
  align-items: center;
  top: 20px;
  left: 0;
  width: 375px;
  height: 35px;
  // background-color: pink;
  padding: 0 15px;
  .search {
    display: flex;
    align-items: center;
    width: 310px;
    height: 35px;
    border-radius: 5px;
    background-color: white;
    padding: 0 8px;
    font-size: 15px;
    .location {
      .city {
        margin-right: 5px;
      }
      .van-icon-arrow-down {
        font-size: 14px;
      }
    }
    .formInp {
      margin-left: 20px;
      border-left: 1px solid #e6e6e6;
      color: #9ca0a2;
      font-size: 14px;
      .van-icon-search {
        font-size: 18px;
        margin: 0 8px 0 10px;
      }
    }
  }
  .van-icon-aim {
    font-size: 25px;
    color: white;
  }
}
.van-grid {
  #circular {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #f1fdf8;
    margin-bottom: 15px;
    text-align: center;
    line-height: 60px;
    .van-icon {
      font-size: 30px;
      color: #00b96d;
    }
  }
  .rentText {
    font-size: 14px;
  }
}
.rent_group {
  // height: 232px;
  background-color: #f7f6f7;
  padding: 10px;
  .rent_group_hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 40px;
    // background-color: pink;
    padding: 0 10px 0 10px;
    font-size: 14px;
    em {
      font-weight: 700;
    }
    i {
      color: #797e84;
      padding-left: 20px;
    }
  }
  .rent_group_bd {
    display: flex;
  }
}
.newmessage {
  width: 100%;
  // height: 300px;
  // background-color: pink;
  p {
    background-color: #fff;
    font-weight: 700;
    height: 50px;
    line-height: 50px;
    padding-left: 20px;
  }
  .houseinfo {
    display: flex;
    // height: 100px;
    // background-color: #00b96d;
    padding: 10px 30px;
    .info_l {
      width: 120px;
      // height: 50px;
      background-color: #fff;
      img {
        width: 100%;
      }
    }
    .info_r {
      // background-color: yellow;
      padding: 0 5px 0 20px;
      span {
        display: inline-block;
        color: gray;
        font-size: 12px;
        margin-top: 20px;
      }
      i {
        display: inline-block;
        color: gray;
        font-size: 12px;
        margin-top: 20px;
        margin-left: 110px;
      }
    }
  }
}
</style>
